﻿using UnityEngine;
using System.Collections;

public class SceneEffect : PostEffectsBase {

	public Shader briSatConShader;
	private Material briSatConMaterial;
	public Material material {  
		get {
			briSatConMaterial = CheckShaderAndCreateMaterial(briSatConShader, briSatConMaterial);
			return briSatConMaterial;
		}  
	}

	public Texture2D heiTexture;
//	public Texture2D WhiteTexture1;
//	public Texture2D WhiteTexture2;
	private bool change = false;
	private float perTime = 0.5f;
	private float currentDelay = 0f;
	void OnRenderImage(RenderTexture src, RenderTexture dest) {
		currentDelay += Time.deltaTime;
		if (currentDelay > perTime) {
			currentDelay = 0f;
			if (material != null) {
				change = !change;
			}
		}
		if (material != null) {
			material.SetTexture ("_HeiTex", heiTexture);
//			if (change) {
//				material.SetTexture ("_RenderTex", WhiteTexture2);
//			} else {
//				material.SetTexture ("_RenderTex", WhiteTexture1);
//			}
			Graphics.Blit(src, dest, material);
		} else {
			Graphics.Blit(src, dest);
		}
	}
}
